package com.qinggeng.framework.config.mq.impl;
import com.alibaba.fastjson.JSONObject;
import com.qinggeng.common.exception.CustomException;
import com.qinggeng.framework.config.mq.dto.MessageAccountDTO;
import com.qinggeng.framework.config.mq.dto.MessageVipDTO;
import com.qinggeng.framework.config.mq.handle.MessageHandle;
import com.qinggeng.project.system.domain.Member;
import com.qinggeng.project.system.service.IUserAccountService;
import com.qinggeng.project.system.service.MemberService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Slf4j
@Component
public class VipHandleImpl implements MessageHandle {
    @Resource
    MemberService memberService;
    @Override
    public void handle(String msg) {
            System.out.println("解析vip handle "+msg);
        try {
            MessageVipDTO dto=JSONObject.parseObject(msg,MessageVipDTO.class);
            boolean bl=memberService.buyVip(dto.getOrderNo());
            System.out.println("解析vip result "+bl);
        }catch (Exception e){
            throw  new CustomException("錯誤"+e.getMessage());
        }
    }

}
